package com.koron.css2.serviceManage.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.TSubSystemBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.mapper.TSubSystemMapper;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

import java.util.List;

public class TSubSystemList implements ServerInterface {

	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		try {
			TSubSystemBean tSubSystemBean = JsonUtils.objectToPojo(req.getData(), TSubSystemBean.class);
			TSubSystemMapper mapper = factory.getMapper(TSubSystemMapper.class);
			List <TSubSystemBean> tSubSystemBeans = mapper.selectTSubSystem(tSubSystemBean);
			MessageBean<List> info = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success", List.class);
			info.setData(tSubSystemBeans);
			return info;
		} catch (Exception e) {
			logger.error("操作失败", e);
			return MessageBean.create(Constant.MESSAGE_INT_FAIL, "操作失败", Void.class);
		}
	}

}
